package com.tensquare.friend.dao;

import com.tensquare.friend.pojo.Friend;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;

public interface FriendDao extends JpaRepository<Friend,String> {
    //1.查询是否有这个friend
    @Query(nativeQuery=true,value="select * from tb_friend where userid=?1 and friendid=?2")
    Friend findByIdAndFriendid(String userid,String friendid);
    //2.修改islike
    @Modifying
    @Query(nativeQuery=true,value="update tb_friend set islike=?3 where userid=?1 and friendid=?2")
    void updateIsLike(String userid, String friendid, String islike);
    //3.根据userid以及friend删除对象
    @Modifying
    @Query(nativeQuery=true,value="delete from tb_friend where userid=?1 and friendid=?2")
    void deleteByIdAndFriendid(String id, String friendid);
}
